package mushystuff.dtb.web.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class Intro extends BaseController {
    
    @RequestMapping(value="/intro.do")
    public String viewProducts(ModelMap model) {
    	return "dtb.intro";  
    }
    
    @RequestMapping(value="/selectProduct.do", method = RequestMethod.GET)
    public String selectProduct(@RequestParam(value="productId", required=true) long productId, HttpSession session) {
        if (productId == -1) {
            session.removeAttribute("productId");
            return "redirect:intro.do";
        } else {
            session.setAttribute("productId", productId);
            return "redirect:productDashboard.do";
        }
    }
    
}
